<?php
/*
 * 去首页广告数据
 */

require ("../db_conn.php");

$rec=isset($_get['rec'])?$_get['rec']:"";
if ($rec=='insert')
{
     $adname=$_post['adname'];
    $linkurl=$_post['linkurl'];
    $isshow=$_post['isshow'];
    $sql="insert into db_ad(adname,linkurl,isshow) values('$adname','$linkurl',$isshow)";
    $rs=$mysqli->query($sql);
    if ($rs==FALSE)
    {
        echo "<script language='javascript' type='text/javascript'>";
        echo "alert('添加失败！');";
        echo "window.location.href='show.php'";
        echo "</script>";
    } 
}
$sql="SELECT * FROM `db_ad`  order by id desc limit 0,5 ";   //写查询语句  isshow=1   取5个    
$ggrows=$mysqli->query($sql); //执行语句  $rs是一个结果集
$adrowlist=$ggrows->fetch_all(MYSQLI_BOTH);   //包括所有行 $adrows有数据库的焦点广告
require 'show_html.php';
//释放结果集
$ggrows->free();
//关闭数据库
$mysqli->close();
